# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Bernardo Ferrari Mendonca <bernardo.mferrari@gmail.com>
pkgname=coin-or-lemon
pkgver=1.3.1
pkgrel=4
pkgdesc="A C++ template library providing many common graph algorithms"
arch=('loong64' 'x86_64')
url="http://lemon.cs.elte.hu/trac/lemon"
license=('BSD')
depends=('coin-or-cbc' 'coin-or-clp' 'glpk')
makedepends=('cmake' 'ninja' 'doxygen' 'graphviz' 'python')
options=('staticlibs')
source=("http://lemon.cs.elte.hu/pub/sources/lemon-${pkgver}.tar.gz")
sha1sums=('b23d64c21b4b9088ad51e85316964a4a4138f82a')

build() {
  cd "$srcdir/lemon-$pkgver"

  export CXXFLAGS+=" -ffat-lto-objects"
  cmake \
    -Bbuild_static \
    -GNinja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DLEMON_ENABLE_GLPK=ON \
    -DLEMON_ENABLE_ILOG=OFF \
    -DLEMON_ENABLE_COIN=ON \
    -DLEMON_ENABLE_SOPLEX=OFF
  ninja -C build_static

  cmake \
    -Bbuild_shared \
    -GNinja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DBUILD_SHARED_LIBS=ON \
    -DLEMON_ENABLE_GLPK=ON \
    -DLEMON_ENABLE_ILOG=OFF \
    -DLEMON_ENABLE_COIN=ON \
    -DLEMON_ENABLE_SOPLEX=OFF
  ninja -C build_shared
}

package() {
  cd "$srcdir/lemon-$pkgver"
  DESTDIR="$pkgdir" ninja -C build_static install
  DESTDIR="$pkgdir" ninja -C build_shared install

  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
